#sby的高级题目❤☃♔
def aaa():
    print("不要动代码")

def kjl():
    print("就要动你代码")

def 名字():
    print("你好!!!")




# 第一题
# def oper(num,num1,num2):
#
#     if num < 100:
#
#         return num1 * num2
#
#     return num1 + num2
#
# print(oper(1314,52,0))  # 52
# print(oper(5,2,0))      # 0


# 第二题 封装一个函数，把一个文件中的内容，复制到另外一个文件中
# file1 = open("D://python.txt", "r")
# file2 = open("D://test.txt", "w")
#
# str = file1.read()
# file2.write(str)
#
# file1.close()
# file2.close()

def copy_file(s_path, d_path):
    """
    参数:
        s_path (str): 源文件路径
        d_path (str): 目标文件路径
    """
    with open(s_path, 'rb') as src_file:
        with open(d_path, 'wb') as dest_file:
            while True:
                chunk = src_file.read(4096)  # 每次读取4KB
                if not chunk:
                    break
                dest_file.write(chunk)

if __name__ == "__main__":
    source = "D:\\python.txt"
    destination = "D:\\test.txt"
    copy_file(source, destination)
    print(f"文件 {source} 已复制到 {destination}")



# 第四题：四、面向对象实现人狗大战
# 1. 人狗初始血量值100，人攻击力10，狗攻击力8；
# 2. 可以普通攻击和技能攻击（每攻击三次发动一次技能）；
# 3. 人狗均可以防御，防御减伤本次所受伤害的50%。（30%概率防御）。
# import random
# class Character:
#     def __init__(self, name, hp, attack):
#         self.name = name
#         self.max_hp = hp
#         self.hp = hp
#         self.attack = attack
#         self.attack_count = 0
#         self.is_defending = False
#
#     def perform_attack(self, target):
#         if self.attack_count % 3 == 2:  # 每3次攻击发动一次技能
#             damage = self.skill_attack()
#         else:
#             damage = self.normal_attack()
#
#         self.attack_count += 1
#         target.take_damage(damage)
#
#     def normal_attack(self):
#         print(f"{self.name}发动普通攻击!")
#         return self.attack
#
#     def skill_attack(self):
#         # 技能攻击伤害是普通攻击的1.5倍
#         damage = int(self.attack * 1.5)
#         print(f"{self.name}发动技能攻击! 造成{damage}点伤害!")
#         return damage
#
#     def take_damage(self, damage):
#         # 30%概率防御
#         if random.random() < 0.3:
#             self.is_defending = True
#             damage = damage // 2
#             print(f"{self.name}进行了防御! 伤害减半!")
#         else:
#             self.is_defending = False
#
#         self.hp -= damage
#         if self.hp < 0:
#             self.hp = 0
#         print(f"{self.name}受到了{damage}点伤害! 剩余血量: {self.hp}")
#
#     def is_alive(self):
#         return self.hp > 0
#
#
# class Human(Character):
#     def __init__(self):
#         super().__init__("人类", 100, 10)
#
#     def skill_attack(self):
#         # 人类的技能攻击是普通攻击的2倍
#         damage = self.attack * 2
#         print(f"{self.name}发动致命一击! 造成{damage}点伤害!")
#         return damage
#
#
# class Dog(Character):
#     def __init__(self):
#         super().__init__("狗狗", 100, 8)
#
#     def skill_attack(self):
#         # 狗狗的技能攻击是普通攻击的1.8倍，并有概率连击
#         damage = int(self.attack * 1.8)
#         print(f"{self.name}发动疯狂撕咬! 造成{damage}点伤害!")
#
#         # 50%概率追加一次普通攻击
#         if random.random() < 0.5:
#             print(f"{self.name}发动了连击!")
#             damage += self.attack
#
#         return damage
#
#
# def battle():
#     human = Human()
#     dog = Dog()
#     round_num = 1
#
#     while human.is_alive() and dog.is_alive():
#         print(f"\n=== 第{round_num}回合 ===")
#
#         # 人类攻击
#         human.perform_attack(dog)
#         if not dog.is_alive():
#             break
#
#         # 狗狗攻击
#         dog.perform_attack(human)
#         if not human.is_alive():
#             break
#
#         round_num += 1
#
#     # 宣布胜利者
#     if human.is_alive():
#         print("\n人类获胜!")
#     else:
#         print("\n狗狗获胜!")
#
#
# if __name__ == "__main__":
#     print("人狗大战开始!")
#     battle()